package p03_SingleLinkedList;

import org.junit.jupiter.api.Test;

public class P1 {
    @Test
    public void test01() {
        HeroList heros = new HeroList();
        HeroNode hero1 = new HeroNode(1, "hero1", "nick1");
        HeroNode hero2 = new HeroNode(2, "hero2", "nick2");
        HeroNode hero3 = new HeroNode(3, "hero3", "nick3");
        HeroNode hero4 = new HeroNode(4, "hero4", "nick4");
        heros.add(hero1);
        heros.add(hero2);
        heros.add(hero3);
        heros.add(hero4);
        heros.print();
    }

    @Test
    public void test02() {
        HeroList heros = new HeroList();
        HeroNode hero1 = new HeroNode(1, "hero1", "nick1");
        HeroNode hero2 = new HeroNode(2, "hero2", "nick2");
        HeroNode hero3 = new HeroNode(3, "hero3", "nick3");
        HeroNode hero4 = new HeroNode(4, "hero4", "nick4");
        heros.addByOrder(hero2);
        heros.addByOrder(hero3);
        heros.addByOrder(hero1);
        heros.addByOrder(hero4);
        heros.print();
    }

    @Test
    public void test03() {
        HeroList heros = new HeroList();
        HeroNode hero1 = new HeroNode(1, "hero1", "nick1");
        HeroNode hero2 = new HeroNode(2, "hero2", "nick2");
        HeroNode hero3 = new HeroNode(3, "hero3", "nick3");
        HeroNode hero4 = new HeroNode(4, "hero4", "nick4");
        heros.addByOrder(hero2);
        heros.addByOrder(hero3);
        heros.addByOrder(hero1);
        heros.addByOrder(hero4);
        heros.print();

        heros.update(new HeroNode(1, "hero5", "nick5"));
        System.out.println("=========");
        heros.print();
    }

    @Test
    public void test04() {
        HeroList heros = new HeroList();
        HeroNode hero1 = new HeroNode(1, "hero1", "nick1");
        HeroNode hero2 = new HeroNode(2, "hero2", "nick2");
        HeroNode hero3 = new HeroNode(3, "hero3", "nick3");
        HeroNode hero4 = new HeroNode(4, "hero4", "nick4");
        heros.addByOrder(hero2);
        heros.addByOrder(hero3);
        heros.addByOrder(hero1);
        heros.addByOrder(hero4);
        heros.print();

        heros.delete(3);
        heros.delete(2);
        System.out.println("=========");
        heros.print();
    }

    @Test
    public void test05() {
        HeroList heros = new HeroList();
        HeroNode hero1 = new HeroNode(1, "hero1", "nick1");
        HeroNode hero2 = new HeroNode(2, "hero2", "nick2");
        HeroNode hero3 = new HeroNode(3, "hero3", "nick3");
        HeroNode hero4 = new HeroNode(4, "hero4", "nick4");
        heros.addByOrder(hero2);
        heros.addByOrder(hero3);
        heros.addByOrder(hero1);
        heros.addByOrder(hero4);
        heros.print();

        System.out.println("=========");
        System.out.println(heros.get(5));
    }

    @Test
    public void test06() {
        HeroList heros = new HeroList();
        HeroNode hero1 = new HeroNode(1, "hero1", "nick1");
        HeroNode hero2 = new HeroNode(2, "hero2", "nick2");
        HeroNode hero3 = new HeroNode(3, "hero3", "nick3");
        HeroNode hero4 = new HeroNode(4, "hero4", "nick4");
        heros.addByOrder(hero2);
        heros.addByOrder(hero3);
        heros.addByOrder(hero1);
        heros.addByOrder(hero4);

        System.out.println(Utils.getLength(heros));
    }

    @Test
    public void test07() {
        HeroList heros = new HeroList();
        HeroNode hero1 = new HeroNode(1, "hero1", "nick1");
        HeroNode hero2 = new HeroNode(2, "hero2", "nick2");
        HeroNode hero3 = new HeroNode(3, "hero3", "nick3");
        HeroNode hero4 = new HeroNode(4, "hero4", "nick4");
        heros.addByOrder(hero2);
        heros.addByOrder(hero3);
        heros.addByOrder(hero1);
        heros.addByOrder(hero4);
        heros.print();

        System.out.println("========");
        System.out.println(Utils.getReverse(heros, 1));
        System.out.println(Utils.getReverse(heros, 2));
        System.out.println(Utils.getReverse(heros, 3));
        System.out.println(Utils.getReverse(heros, 4));
        System.out.println(Utils.getReverse(heros, 0));
        System.out.println(Utils.getReverse(heros, -10));
    }
}
